#include <iostream>
#include <mysql/mysql.h>
#include "MysqlConn.h"
using namespace std;
/* g++ main.cpp -lmysqlclient 
必须在root文件中执行，su命令*/

int query()
{
    MysqlConn conn;
    conn.connect("localhost", "root", "1", "musicDB");
    
    /* 插入数据 */
    string sql = "INSERT INTO userInfo (username, age) VALUES('lili', 20); ";
    if(conn.update(sql))
    {
        cout << "插入成功" << endl;
    }

    sql = "select * from userInfo";
    conn.query(sql);
    while(conn.next())
    {
        cout << conn.value(0) << ","
        << conn.value(1) << ","
        << conn.value(2) << ","
        << conn.value(3) << endl;
    }
    return 0;
}

int main()
{
    query();
    return 0;
}